<template>
  <body class=" d-flex flex-column" @keyup.enter="doLogin">
  <div class="page page-center">
    <div class="container container-tight py-4">
      <div class="text-center mb-4">
        <a href="." class="navbar-brand navbar-brand-autodark"><img src="./static/logo.svg" height="36" alt=""></a>
      </div>
      <div class="card card-md">
        <div class="card-body">
          <h2 class="h2 text-center mb-4">Login to your account</h2>
          <form action="./" method="get" autocomplete="off" novalidate>
            <div class="mb-3">
              <label class="form-label">用户名</label>
              <input type="text" class="form-control" placeholder="用户名" autocomplete="off" v-model="username">
            </div>
            <div class="mb-2">
              <label class="form-label">
                密码
                <span class="form-label-description">
                    <a href="/forgotPassword">忘记密码</a>
                  </span>
              </label>
              <div class="input-group input-group-flat">
                <input type="password" class="form-control" placeholder="密码" autocomplete="off" v-model="password">
                <span class="input-group-text">
                    <a href="#" class="link-secondary" title="Show password" data-bs-toggle="tooltip"><!-- Download SVG icon from http://tabler-icons.io/i/eye -->
                      <svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24"
                           stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"
                           stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path
                          d="M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"/><path
                          d="M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"/></svg>
                    </a>
                  </span>
              </div>
            </div>
            <div class="mb-2">
              <label class="form-check">
                <input type="checkbox" class="form-check-input"/>
                <span class="form-check-label">Remember me on this device</span>
              </label>
            </div>
            <div class="form-footer">
              <button type="button" class="btn btn-primary w-100" @click="doLogin">Sign in</button>
            </div>
          </form>
        </div>
        <div class="hr-text">or</div>
        <div class="card-body">
          <div class="row">
            <div class="col"><a href="#" class="btn w-100">
              <!-- Download SVG icon from http://tabler-icons.io/i/brand-github -->
              <svg xmlns="http://www.w3.org/2000/svg" class="icon text-github" width="24" height="24"
                   viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"
                   stroke-linejoin="round">
                <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
                <path
                    d="M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5"/>
              </svg>
              Login with Github
            </a></div>
            <div class="col"><a href="#" class="btn w-100">
              <!-- Download SVG icon from http://tabler-icons.io/i/brand-twitter -->
              <WechatOutlined/> &nbsp;
              Login with Wechat
            </a></div>
          </div>
        </div>
      </div>
      <div class="text-center text-muted mt-3">
        Don't have account yet? <a href="/signUp" tabindex="-1">Sign up</a>
      </div>
    </div>
  </div>
  <!-- Libs JS -->
  <!-- Tabler Core -->
  </body>
</template>

<script>
import {WechatOutlined} from '@ant-design/icons-vue';
import {loginPass} from "@/api/auth.js";
import {setTokenExpired, setUserName} from "@/utils/auth.js";
import {mapActions} from "vuex";
import {router} from "@/main.js";


export default {
  name: "SignIn",
  data() {
    return {
      username: null,
      password: null
    }
  },
  methods: {
    ...mapActions([
      'navigationChange',
      'Register',
      'increment',
      'login_count',
      'Logout',
      'login',
      'login2'
    ]),
    doLogin() {
      console.log('doLogin……')
      this.login({username: this.username, password: this.password});
    },
    // async doLogin2() {
    //   let res = await this.login2({username: this.username, password: this.password})
    //   console.log('res:', res)
    //   if (res.data.code!==200){
    //     layer.msg(res.data.data)
    //   }else{
    //     layer.msg('登录成功')
    //     router.push('/')
    //   }
    // }

  }
}
</script>

<style scoped>

</style>
